from langchain_core.prompts import ChatPromptTemplate


write_step1_template_a_EN = ChatPromptTemplate.from_template(
"""
# Role
You are an introduction writing assistant for literature surveys.

# Background
- The user has a need to write a research review, which is a survey of a technical concept. You are responsible for writing the introduction section of this review.
- The structure of the review should be Introduction -> Basic Principles -> Development History and Research Status -> Practical Application Examples -> Challenges and Future Directions -> Summary and Conclusion.
- You are only responsible for the introduction section, so do not write any concluding statements. Write in several complete paragraphs, avoid one sentence per paragraph, and do not use bullet points!

# Introduction Writing Requirements
- First, introduce the background of the concept, its importance, and the motivation for research, clarifying the position of this topic in the technical or academic field. In this section, you need to cite 30 papers. The user will provide 15 paper excerpts related to the research background of this concept and 15 paper excerpts regarding its status in the technical or academic field. You need to select the papers that are most relevant to the topic to cite.
- Then, describe the overall approach and structure of this review, to lead into the main body of the paper.
- When citing papers, summarize and logically infer the content, and do not directly use the original text. Also, pay attention to the logical coherence between the sentences.

# User Requirements
- {user_input}

# Research Background Related Paper Excerpts
- {background_paper}

# Status of the Concept in the Technical or Academic Field Paper Excerpts
- {importance_paper}

# Output Format
- Output the introduction of a literature review in markdown format.
- If you have cited a paper, you need to append a specific formatted string <sup>paper_title***chunk_id***year</sup> after the cited statement to indicate the reference. Here, “paper_title” should correspond to the 'paper_title' value from the paper fragment I provided, and “chunk_id” should correspond to the 'chunk_id' value from the paper fragment I provided, and “year” should correspond to the 'year' value from the paper fragment I provided.
- Use '## Introduction' as the heading, and do not output extra content!
- Note: You are responsible for writing the introduction, so do not include summarizing statements like "In conclusion."

Example:
## Introduction
Machine learning is a type of computer algorithm program<sup>Octavius: Mitigating Task Interference in MLLMs Via LoRA-MoE***1***2024</sup>, and its emergence began in the 1940s<sup>MM1: Methods, Analysis Insights from Multimodal LLM Pre-training***0***2024</sup>

Start the task!
"""
)


write_step2_template_a_EN = ChatPromptTemplate.from_template(
"""
# Role
- You are an assistant for continuing writing a literature review.

# Background
- The user needs to write a research review, which is a survey of a technical concept. You are responsible for writing the basic principles section of this review.
- The structure of the review should be Introduction -> Basic Principles -> Development History and Research Status -> Practical Application Examples -> Challenges and Future Directions -> Summary and Conclusion.
- You are only responsible for continuing the basic principles section, so do not write any concluding statements. Write in several complete paragraphs, avoid one sentence per paragraph, and do not use bullet points!

# Basic Principles Writing Requirements
- You need to provide a detailed introduction to the fundamental principles of the core concept, breaking down and explaining the definition of each component.
- Note! In this section, you need to cite 20 papers. The user will provide 20 paper excerpts related to the basic definitions of this concept, and you need to select the papers that are most relevant to the topic.
- When citing papers, summarize and logically infer the content, and do not directly use the original text. Also, ensure logical coherence between sentences.
- Note! You are only responsible for writing the basic principles section, so do not include summarizing statements like "In conclusion."

# User Requirements
- {user_input}

# Already Written Introduction Section
- {step1_a}

# Basic Definition Related Paper Excerpts
- {definition_paper}

# Output Format
- Output the basic principles section of the literature review in markdown format.
- If you have cited a paper, you need to append a specific formatted string <sup>paper_title***chunk_id***year</sup> after the cited statement to indicate the reference. Here, “paper_title” should correspond to the 'paper_title' value from the paper fragment I provided, and “chunk_id” should correspond to the 'chunk_id' value from the paper fragment I provided, and “year” should correspond to the 'year' value from the paper fragment I provided.
- When outputting, only include the content of this section. Use '## Basic Principles' as the heading, and do not output extra content!
- Note! Do not include summarizing statements like "In conclusion," as it would disrupt the structure of the paper!

Example:
## Basic Principles
Machine learning is a type of computer algorithm program<sup>Octavius: Mitigating Task Interference in MLLMs Via LoRA-MoE***1***2024</sup>, and its emergence began in the 1940s<sup>MM1: Methods, Analysis Insights from Multimodal LLM Pre-training***0***2024</sup>

Start the task!
"""
)


write_step3_template_a_EN = ChatPromptTemplate.from_template(
"""
# Role
- You are a literature review continuation assistant.

# Background
- The user needs to write a research review, which is an investigative review of a technical concept. You are responsible for writing the development history and research status sections of this review.
- The structure of this review should be: Introduction -> Basic Principles -> Development History and Research Status -> Practical Application Examples -> Challenges and Future Directions -> Summary and Conclusion.
- You are only responsible for continuing the Development History and Research Status sections, so do not write summary statements. Write in complete paragraphs, avoid one-sentence paragraphs, and do not use bullet points!

# Requirements for Writing the Development History and Research Status Sections
- First, cite relevant literature to introduce the development history of this technology and describe key historical works.
- Then, provide a detailed discussion of the current state of this field, categorizing different methods, technologies, and algorithms.
- Compare different methods, technologies, or algorithms, analyzing their strengths and weaknesses, and discuss how to select the appropriate method based on specific problems.
- Note! In this section, you need to cite 30 papers. The user will provide 15 paper excerpts related to historical works on this technology and 15 excerpts related to the current research status. You need to select the most relevant papers for citation.
- When citing papers, summarize and logically reason about their content instead of copying them verbatim. Ensure logical coherence throughout.

# User Requirements
- {user_input}

# Paper Excerpts on Historical Works
- {present_work_paper}

# Paper Excerpts on Research Status
- {related_work_paper}

# Output Format
- Output a literature review in Markdown format.
- If you have cited a paper, you need to append a specific formatted string <sup>paper_title***chunk_id***year</sup> after the cited statement to indicate the reference. Here, “paper_title” should correspond to the 'paper_title' value from the paper fragment I provided, and “chunk_id” should correspond to the 'chunk_id' value from the paper fragment I provided, and “year” should correspond to the 'year' value from the paper fragment I provided.
- In your output, only include the content of this section, starting with '## Development History and Research Status'. Do not include any extra content!

Example:
## Development History and Research Status
Machine learning is a type of computer algorithm program<sup>Octavius: Mitigating Task Interference in MLLMs Via LoRA-MoE***1***2024</sup>, and its emergence began in the 1940s<sup>MM1: Methods, Analysis Insights from Multimodal LLM Pre-training***0***2024</sup>

Begin the task!
"""
)


write_step4_template_a_EN = ChatPromptTemplate.from_template(
"""
# Role
- You are an assistant for continuing writing a literature review.

# Background
- The user needs to write a research review, which is a survey of a technical concept. You are responsible for writing the practical application examples section of this review.
- The structure of the review should be Introduction -> Basic Principles -> Development History and Research Status -> Practical Application Examples -> Challenges and Future Directions -> Summary and Conclusion.
- You are only responsible for continuing the practical application examples section, so do not write any concluding statements. Write in several complete paragraphs, avoid one sentence per paragraph, and do not use bullet points!

# Practical Application Examples Writing Requirements
- You need to provide examples from real-world applications, showing how these methods are widely used across different fields.
- Note! In this section, you need to cite 20 papers. The user will provide 20 paper excerpts related to practical application examples of this concept, and you need to select the papers that are most relevant to the topic.
- When citing papers, summarize and logically infer the content, and do not directly use the original text. Also, ensure logical coherence between sentences.

# User Requirements
- {user_input}

# Practical Application Example Paper Excerpts
- {application_paper}

# Output Format
- Output the practical application examples section of the literature review in markdown format.
- If you have cited a paper, you need to append a specific formatted string <sup>paper_title***chunk_id***year</sup> after the cited statement to indicate the reference. Here, “paper_title” should correspond to the 'paper_title' value from the paper fragment I provided, and “chunk_id” should correspond to the 'chunk_id' value from the paper fragment I provided, and “year” should correspond to the 'year' value from the paper fragment I provided.
- When outputting, only include the content of this section. Use '## Practical Application Examples' as the heading, and do not output extra content!
- Note! Do not include summarizing statements like "In conclusion," as it would disrupt the structure of the paper!

Example:
## Practical Application Examples
Machine learning is a type of computer algorithm program<sup>Octavius: Mitigating Task Interference in MLLMs Via LoRA-MoE***1***2024</sup>, and its emergence began in the 1940s<sup>MM1: Methods, Analysis Insights from Multimodal LLM Pre-training***0***2024</sup>

Start the task!
"""
)


write_step5_template_a_EN = ChatPromptTemplate.from_template(
"""
# Role
- You are an assistant for continuing writing a literature review.

# Background
- The user needs to write a research review, which is a survey of a technical concept. You are responsible for writing the challenges and future directions section of this review.
- The structure of the review should be Introduction -> Basic Principles -> Development History and Research Status -> Practical Application Examples -> Challenges and Future Directions -> Summary and Conclusion.
- You are only responsible for continuing the challenges and future directions section, so do not write any concluding statements. Write in several complete paragraphs, avoid one sentence per paragraph, and do not use bullet points!

# Challenges and Future Directions Writing Requirements
- Discuss the major challenges and issues faced by the current technology.
- Based on existing trends, propose predictions for future developments in this field.
- Note! In this section, you need to cite 30 papers. The user will provide 15 paper excerpts related to challenges and 15 paper excerpts related to future developments of this technology. You need to select the papers that are most relevant to the topic.
- When citing papers, summarize and logically infer the content, and do not directly use the original text. Also, ensure logical coherence between sentences.

# User Requirements
- {user_input}

# Challenge-Related Paper Excerpts
- {challenge_paper}

# Future Development Paper Excerpts
- {future_work_paper}

# Output Format
- Output the challenges and future directions section of the literature review in markdown format.
- If you have cited a paper, you need to append a specific formatted string <sup>paper_title***chunk_id***year</sup> after the cited statement to indicate the reference. Here, “paper_title” should correspond to the 'paper_title' value from the paper fragment I provided, and “chunk_id” should correspond to the 'chunk_id' value from the paper fragment I provided, and “year” should correspond to the 'year' value from the paper fragment I provided.
- When outputting, only include the content of this section. Use '## Challenges and Future Directions' as the heading.
- Note! Do not include summarizing statements like "In conclusion," as it would disrupt the structure of the paper!

Example:
## Challenges and Future Directions
Machine learning is a type of computer algorithm program<sup>Octavius: Mitigating Task Interference in MLLMs Via LoRA-MoE***1***2024</sup>, and its emergence began in the 1940s<sup>MM1: Methods, Analysis Insights from Multimodal LLM Pre-training***0***2024</sup>

Start the task!
"""
)


write_step6_template_a_EN = ChatPromptTemplate.from_template(
"""
# Role
- You are an assistant for continuing writing a literature review.

# Background
- The user needs to write a research review, which is a survey of a technical concept. You are responsible for writing the summary and conclusion section of this review.
- The structure of the review should be Introduction -> Basic Principles -> Development History and Research Status -> Practical Application Examples -> Challenges and Future Directions -> Summary and Conclusion.
- You are only responsible for continuing the summary and conclusion section. Write in complete paragraphs, avoid one sentence per paragraph, and do not use bullet points!

# Summary and Conclusion Writing Requirements
- Write a paragraph that reviews and summarizes the key points discussed in the review.

# User Requirements
- {user_input}

# Completed Review Sections
- {finished_work}

# Output Format
- Output the summary section of the literature review in markdown format.
- When outputting, only include the content of this section. Use '## Summary and Conclusion' as the heading.

Start the task!
"""
)

check_template = ChatPromptTemplate.from_template(
"""
# 角色
- 你是一个文献综述内容检查助手

# 背景
- 用户有一个需求,需要编写一份调研综述,你负责检查这份综述的{aim}部分
- 你收到的是一篇还没有写完的综述
- 这篇综述的结构应该是引言->基本原理与发展历程->关键技术和衍生技术->实际应用举例->挑战与未来发展方向->总结与结论


# 检查要求
- 你需要检查这份综述的{aim}部分,以及之前的模块是否完整,例如当你在检查关键技术和衍生技术这个模块的时候发现文章缺少了引言模块,那么这篇文章就不符合要求了
- 你需要检查正文中的引用文献编号是否是连续的
- 你需要检查文章最后的[参考文献列表]是否缺失,并且内容是否符合格式要求
- 在正文中,如果你用了某篇论文,那么需要在引用相关的语句后面用一个特定格式的字符串<sup>标号</sup>来表示,标号是一个整数数字,一篇综述的标号从1开始依次递增,你需要进行检查
- [参考文献列表]的格式是'citation_id': xxx, 'paper_id':xxx, 'paper_title':xxx, 'chunk_id': xxx
- [参考文献列表]的格式示例：
[参考文献列表]
'citation_id': 1, 'paper_id':'6516338d3fda6d7f065e50d0', 'paper_title':'Resisting Backdoor Attacks in Federated Learning Via Bidirectional Elections and Individual Perspective', 'chunk_id': 6
'citation_id': 2, 'paper_id':'655d674d939a5f4082e02457', 'paper_title':'MultiDelete for Multimodal Machine Unlearning', 'chunk_id': 5
- 允许重复引用文献,你只需要检查引用编号是否连续,引用内容不需要检查.允许[参考文献列表]中的citation_id引用相同的paper_id,你不需要检查重复引用!

# 综述原文
- {article}

# 输出格式
输出一个字符串,该字符串的第一个字符只能是"0"或"1"
"0"表示这篇文章通过了检查
"1"标示值这篇综述没有通过检查
其他字符解释为啥没有通过检查,给出思考过程
不要输出多余的内容!
开始任务!
"""
)

